from save import Save

class BasePlayer:
    maxHP=0
    baseDef=0
    baseMDef=0
    baseAtk=0

class Player(BasePlayer):
    baseMaxHP = 4
    baseDef = 1
    baseMDef =0.2
    baseAtk = 1
    def __init__(self) -> None:
        self.maxHP = self.baseMaxHP
        self.HP = self.maxHP
        self.def_ = self.baseDef
        self.mDef = self.baseMDef
        self.atk = self.baseAtk
        self.alive = True

    def toSave(self, save:Save) -> None:
        player_data = {}
        player_data["maxHP"] = self.maxHP
        player_data["HP"] = self.HP
        player_data["def"] = self.def_
        player_data["mDef"] =self.mDef
        player_data["atk"] = self.atk
        save.data["player"] = player_data

    def fromSave(self, save:Save) -> None:
        player_data = save.data["player"]
        self.maxHP = player_data["maxHP"]
        self.HP = player_data["HP"]
        self.def_ = player_data["def"]
        self.mDef = player_data["mDef"]
        self.atk = player_data["atk"]

        self.alive = self.HP > 0